#include<cstdio>
#include<cstring>
using namespace std;
const int MAX = 1000005;
int ans[MAX], next[MAX], flag = 0, k = 0;

void getNext(int next[], char s[]){
	int k = -1, len = strlen(s);
	next[0] = -1;
	for(int i=0;i<len-1;){
		if(k == -1 || s[i] == s[k]){
			k++;
			i++;
			if(s[i] == s[k]){
				next[i] = next[k];
			}else{
				next[i] = k;
			}
		}else{
			k = next[k];
		}
	}
}

int kmp(char s[], char t[]){
	int lens = strlen(s), lent = strlen(t), i = 0, j = 0;
	getNext(next, t);
	while(i < lens){
		while(i < lens && j < lent){
			if(j == -1 || s[i] == t[j]){
				i++;
				j++;
			}else{
				j = next[j];
			}
		}
		printf("%d ", i - lent);
		if(i == lens){
			break;
		}
		i = i - lent + 1;
		j = 0;
	}
}

int main(){
	char s[MAX], t[MAX];
	scanf("%s %s", s, t);
	
	kmp(s, t);
	
	return 0;
}
